#include <OneWire.h>
 #include <DallasTemperature.h>
 // 数据线已插入Arduino上的端口2
 #define ONE_WIRE_BUS 2
 // 设置oneWire实例以与任何oneWire设备通信
 OneWire oneWire(ONE_WIRE_BUS);
 // 通过我们的oneWire参考达拉斯温度
 DallasTemperature sensors(&oneWire);
 // N个ds18b20的地址（如没达到则留空，最高支持10个ds18b20）
 uint8_t sensor1[8] = { 0x28, 0xD7, 0x74, 0xEB, 0x19, 0x13, 0x01, 0xD3 };
 uint8_t sensor2[8] = { 0x28, 0xBC, 0x02, 0xD7, 0x19, 0x13, 0x01, 0x43 };
 uint8_t sensor3[8] = { 0x28, 0x49, 0xCE, 0xD2, 0x19, 0x13, 0x01, 0x58 };
 uint8_t sensor4[8] = { 0x28, 0x02, 0x92, 0xE1, 0x19, 0x13, 0x01, 0xA1 };
 uint8_t sensor5[8] = { 0x28, 0xB5, 0xA2, 0xD4, 0x19, 0x13, 0x01, 0x6E };
 uint8_t sensor6[8] = { 0x28, 0xD7, 0x98, 0xE4, 0x19, 0x13, 0x01, 0xB2 };
 uint8_t sensor7[8] = { 0x28, 0x34, 0x15, 0xE0, 0x19, 0x13, 0x01, 0xEB };
 uint8_t sensor8[8] = { 0x28, 0x65, 0xDA, 0xD0, 0x19, 0x13, 0x01, 0xF7 };

 void setup(void)
 {
   Serial.begin(9600);
   sensors.begin();
 }

 void loop(void)//循环输出温度
 {
   sensors.requestTemperatures();
   
   Serial.print("Sensor 1: ");
   printTemperature(sensor1);
   
   Serial.print("Sensor 2: ");
   printTemperature(sensor2);
   
   Serial.print("Sensor 3: ");
   printTemperature(sensor3);

   Serial.print("Sensor 4: ");
   printTemperature(sensor3);
   
   Serial.print("Sensor 5: ");
   printTemperature(sensor3);

   Serial.print("Sensor 6: ");
   printTemperature(sensor3);

   Serial.print("Sensor 7: ");
   printTemperature(sensor3);

   Serial.print("Sensor 8: ");
   printTemperature(sensor3);

   Serial.println();
   delay(1000);
 }
 void printTemperature(DeviceAddress deviceAddress)
 {
   float tempC = sensors.getTempC(deviceAddress);
   Serial.print(tempC);
   Serial.print((char)176);
   Serial.print("C  |  ");
 }